unit RequestClass;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, sqldb,lazutf8,laz2_DOM;
type
  TListOfTransferObjects=TList;
  TStrGuid = String(36);
  TTranseferObject = Class;
  { TTranseferObject }
TTranseferObject = Class(TObject)
  protected
    {Filds}
     FUUID:TStrGuid;
    {Methods}
    function ReadFromXmlNode(DOMNode:TDOMElement):Boolean; Virtual;  Abstract;
    function ReadFromDB(DBConnection:TSQLConnection):Integer; Virtual;   Abstract;
  public
    {Methods}
    function WriteToXmlNode(XmlDocument:TXMLDocument): TDOMElement; Virtual; Abstract;
    class function WriteToXmlFile(FileName:String;TransferObjects:TListOfTransferObjects): Integer;
    function Write2DB(DBConnection:TSQLConnection):Integer; Virtual; Abstract;
    function GetForm(): TForm; Virtual; Abstract;
    {Constructors}
    constructor Create;
    constructor Create(XmlDocument:TXMLDocument;UUID:TStrGuid); //From file
    constructor Create(DBConnection:TSQLConnection;UUID:TStrGuid); //From
    {Propertyes}
    property UUID:TStrGuid read FUUID;
end;

//
  {
   TDriverSchoolObject = Class(TTranseferObject)
   private
     //Filds
     Name:String;
     LicNumber:String;
     LicDate:TDateTime;
     //Private metods
     Function LoadObjectFromFile(FileName:String):Integer;
     Function LoadObjectFromDB(RequestLink:TTransferObjectLink):Integer;
     Function ReturnLicNumber(LicNumber:String):String;
   public
     Constructor Create(Name:String;LicNumber:String;LicDate:TDateTime); Overload; //Create empty object
     Constructor Create(FileName:String); Overload;//Create from file
     Constructor Create(RequestLink:TRequestLink); Overload; //Create from data base
     Function Save(FileName:String):Integer Overload;
     Function Save(DriverSchoolLink:TTransferObjectLink):Integer Overload;


     //Propertyes
   end;
  }



implementation


